﻿using IceCS.EMS.DAL;
using IceCS.EMS.DAL.Services;
using IceCS.EMS.Model;
using System.Collections.Generic;

namespace IceCS.EMS.BLL
{
    public class EmployeeManager
    {
        private EmployeeService _service;
        public EmployeeManager()
        {
            _service = ServiceProvider.EmployeeService;
        }

        /// <summary>
        /// 获取雇员列表
        /// </summary>
        /// <returns></returns>
        public IList<EmployeeModel> GetEmployeeModelList()
        {
            return _service.GetEmployeeModelList();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="employeeID"></param>
        /// <returns></returns>
        private bool Exist(int employeeID)
        {
            return _service.Exist(employeeID);
        }


        /// <summary>
        /// 删除雇员
        /// </summary>
        /// <param name="employeeID"></param>
        /// <returns></returns>
        public int DeleteEmployee(int employeeID)
        {
            if (!Exist(employeeID))
            {
                return -1;
            }
            return _service.DeleteEmployee(employeeID);
        }


        /// <summary>
        /// 根据ID值查找雇员
        /// </summary>
        /// <param name="employeeID"></param>
        /// <returns></returns>
        public EmployeeModel SearchById(int employeeID)
        {
            return _service.SearchById(employeeID);
        }

        /// <summary>
        /// 保存对雇员的修改
        /// </summary>
        /// <param name="employee"></param>
        /// <returns></returns>
        public bool SaveEdit(EmployeeModel employee)
        {
            return _service.SaveEdit(employee);
        }


        /// <summary>
        /// 根据表中的ID取值自动生成新Id
        /// </summary>
        /// <returns></returns>
        public int GetId()
        {
            return _service.GetId();
        }

        /// <summary>
        /// 保存新员工信息
        /// </summary>
        /// <param name="employee"></param>
        /// <returns></returns>
        public bool SaveAdd(EmployeeModel employee)
        {
            return _service.SaveAdd(employee);

        }
    }
}
